home *** CD-ROM | disk | FTP | other *** search
/ Info-Mac 3 / Info_Mac_1994-01.iso / Development / Source / MSG Graphic Effects 1.0 Source / Split scroll U-D.c < prev    next >
Text File  |  1993-08-23  |  3KB  |  93 lines

  1. /*******************************************************************************
  2.  * Copyright © 1992-1993 Mark Pilgrim                                          *
  3.  *                                                                             *
  4.  * This file is provided as is, and may be freely distributed unaltered.  This *
  5.  * message must accompany any copy of this file.  This file may be used or     *
  6.  * modified for use for a non-commercial product provided that appropriate     *
  7.  * credit is given to the author named above.                                  *
  8.  * Commercial use of this source code is prohibited.                           *
  9.  ******************************************************************************/
  10.  
  11. #include "msg misc.h"
  12. #include "msg timing.h"
  13.  
  14. #define        BoxSize        10
  15. #define CorrectTime 4
  16.  
  17. void SplitScrollUD(GrafPtr);
  18.  
  19. /* Draw a line from the topleft to the bottomright of the screen and split the
  20.    screen into two regions.  The top region scrolls down and the bottom region
  21.    scrolls up. */
  22.    
  23. void SplitScrollUD(GrafPtr sourceGrafPtr)
  24. {
  25.     int            x;
  26.     Rect        theTopRect, topdest, theBottomRect, bottomdest;
  27.     Rect        topscrollsource, topscrolldest, bottomscrollsource, bottomscrolldest;
  28.     RgnHandle    toprgn,bottomrgn;
  29.     
  30.     toprgn=NewRgn();
  31.     SetEmptyRgn(toprgn);
  32.     MoveTo(0,0);
  33.     OpenRgn();
  34.         Line(MAIN_WINDOW_WIDTH,0);
  35.         Line(0,MAIN_WINDOW_HEIGHT);
  36.         LineTo(0,0);
  37.     CloseRgn(toprgn);
  38.     
  39.     bottomrgn=NewRgn();
  40.     SetEmptyRgn(bottomrgn);
  41.     MoveTo(0,0);
  42.     OpenRgn();
  43.         Line(0,MAIN_WINDOW_HEIGHT);
  44.         Line(MAIN_WINDOW_WIDTH,0);
  45.         LineTo(0,0);
  46.     CloseRgn(bottomrgn);
  47.     
  48.     topscrollsource=gMainWindow->portRect;
  49.     topscrollsource.bottom-=BoxSize;
  50.     topscrolldest = topscrollsource;
  51.     OffsetRect(&topscrolldest, 0, BoxSize);
  52.     
  53.     topdest = gMainWindow->portRect;
  54.     topdest.bottom=BoxSize;
  55.     
  56.     theTopRect.top=MAIN_WINDOW_HEIGHT-BoxSize;
  57.     theTopRect.bottom=MAIN_WINDOW_HEIGHT;
  58.     theTopRect.left=0;
  59.     theTopRect.right=MAIN_WINDOW_WIDTH;
  60.     
  61.     bottomscrollsource=gMainWindow->portRect;
  62.     bottomscrollsource.top+=BoxSize;
  63.     bottomscrolldest=bottomscrollsource;
  64.     OffsetRect(&bottomscrolldest, 0, -BoxSize);
  65.     
  66.     bottomdest=gMainWindow->portRect;
  67.     bottomdest.top=bottomdest.bottom-BoxSize;
  68.     
  69.     theBottomRect.top=0;
  70.     theBottomRect.bottom=BoxSize;
  71.     theBottomRect.left=0;
  72.     theBottomRect.right=MAIN_WINDOW_WIDTH;
  73.     
  74.     for(x = MAIN_WINDOW_HEIGHT - BoxSize; x >= 0; x -= BoxSize)
  75.     {
  76.         StartTiming();
  77.         CopyBits(&(gMainWindow->portBits), &(gMainWindow->portBits),
  78.                 &topscrollsource, &topscrolldest, 0, toprgn);
  79.         CopyBits(&(sourceGrafPtr->portBits), &(gMainWindow->portBits),
  80.                 &theTopRect, &topdest, 0, toprgn);
  81.         theTopRect.bottom-=BoxSize;
  82.         theTopRect.top-=BoxSize;
  83.         
  84.         CopyBits(&(gMainWindow->portBits), &(gMainWindow->portBits),
  85.                 &bottomscrollsource, &bottomscrolldest, 0, bottomrgn);
  86.         CopyBits(&(sourceGrafPtr->portBits), &(gMainWindow->portBits),
  87.                 &theBottomRect, &bottomdest, 0, bottomrgn);
  88.         theBottomRect.top+=BoxSize;
  89.         theBottomRect.bottom+=BoxSize;
  90.         
  91.         TimeCorrection(CorrectTime);
  92.     }
  93. }